#include<bits/stdc++.h>
#define y1 Y1
#define fi first
#define endl "\n"
#define se second
#define PI acos(-1)
#define int long long
#define pb(x) push_back(x)
#define PII pair<int, int>
#define Yes cout << "Yes\n";
#define No cout << "No\n";
#define YES cout << "YES\n";
#define NO cout << "NO\n";
#define _for(i, a, b) for(int i = a; i <= b; ++i)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;

const int N = 1e5 + 10;
int a[20][20], b[20][20];

signed main() {
	IOS;
	int h1, h2, w1, w2;
	cin >> h1 >> w1;
	_for(i, 0, h1 - 1) {
		_for(j, 0, w1 - 1) {
			cin >> a[i][j];
		}
	}
	cin >> h2 >> w2;
	_for(i, 0, h2 - 1) {
		_for(j, 0, w2 - 1) {
			cin >> b[i][j];
		}
	}
	for(int i = 0; i < (1 << h1); ++i) {
		for(int j = 0; j < (1 << w1); ++j) {
			vector<int>r, c;
			for(int k = 0 ; k < h1; ++k) {
				if(i & (1 << k))r.pb(k);
			}
			for(int l = 0; l < w1; ++l) {
				if(j & (1 << l))c.pb(l);
			}
			if(r.size() != h2 || c.size() != w2)continue;
			bool flag = false;
			for(int k = 0; k < h2; ++k) {
				for(int l = 0; l < w2; ++l) {
					if(a[r[k]][c[l]] != b[k][l]) {
						flag = true;
						break;
					}
				}
			}
			if(!flag) {
				Yes;
				return 0;
			}
		}
	} 
	No;
	return 0;
}

